package com.twd.allcomponent.login.controller;

import com.twd.allcomponent.common.ResultVO;
import com.twd.allcomponent.login.bean.User;
import com.twd.allcomponent.login.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@Api(value = "/",description = "登录")
public class a {
    @Autowired
    private UserService userService;

    public static void main(String[] args) throws InterruptedException {
                long start = System.currentTimeMillis();
                for (int i = 0; i < 100000000; i++) {
                    alloc();
                }
                long end = System.currentTimeMillis();
                System.out.println("花费的时间为： " + (end - start) + " ms");
//                System.gc();
                // 为了方便查看堆内存中对象个数，线程sleep
                TimeUnit.MINUTES.sleep(5);
    }
    private static void alloc() {
        byte[] data = new byte[10];//未发生逃逸
    }
    /**
     * 登录
     * @return
     */
    @ApiOperation("登录")
    @PostMapping("/login")
    public ResultVO<String> login(@RequestBody User req){
        return userService.login(req);
    }

}
